TKey
TValue
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedKeyValuePairs<TKey,TValue> Class

Glossary Item Box

Speicalizes the OrderedEnumeration of T to use key/value pairs with a key comparer.

Syntax

Visual Basic (Declaration) 
Public Class OrderedKeyValuePairs
    (Of TKey,TValue) 
   Inherits CSharpTest.Net.Collections.OrderedEnumeration(Of KeyValuePair(Of TKey,TValue))

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestOrderedEnumeration.cs

C#Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NETCopy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Collections.OrderedEnumeration<T>
      CSharpTest.Net.Collections.OrderedKeyValuePairs<TKey,TValue>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys